#!/bin/bash
#

function check_server_disk() {
    disk_size=`df -h | grep "/dev/vda1" | awk '{print $5}' | awk -F '%' '{print $1}'`

    if [ $disk_size -gt 70 ]; then
        echo "$(date +%Y-%m-%d" "%H:%M:%S) - - server disk space is more than 70%, start clear log script."

        cat /dev/null > "/applications/crontab-admin-22000/logs/catalina.out"
        cat /dev/null > "/applications/tomcat-xdatum-search-api-14600/apache-tomcat-8.5.50/logs/catalina.out"
        cat /dev/null > "/data/applogs/crontab/crontab-executor-springboot.log"
    else
        echo "$(date +%Y-%m-%d" "%H:%M:%S) - - server disk space use $disk_size%, server disk space enough."
    fi
}

while true; do
    check_server_disk
    sleep 30s
done
